#!/usr/bin/env node
// 指定运行环境

const ejs = require("ejs");
const inquirer = require("inquirer");
const fs = require("fs");

const process = require("process");

const path = require("path");

console.log(process.cwd());

inquirer
  .prompt([
    {
      type: "input",
      message: "输入你的名字",
      name: "value", // 本次交互数据的键名称
    },
  ])
  .then((res) => {
    const resHtml = ejs.render(
      fs.readFileSync(
        path.resolve(__dirname, "./templete/index.html"),
        "utf-8"
      ),
      {
        title: res.value,
      }
    );
    resHtml && fs.writeFileSync(process.cwd() + "/index.html", resHtml, "utf-8");
    const resHtml1 = ejs.render(
        fs.readFileSync(
          path.resolve(__dirname, "./templete/vue.ejs"),
          "utf-8"
        ),
        {
          title: res.value,
        }
      );
      resHtml1 && fs.writeFileSync(process.cwd() + "/vue.vue", resHtml1, "utf-8");
      const resHtml2 = ejs.render(
        fs.readFileSync(
          path.resolve(__dirname, "./templete/react.ejs"),
          "utf-8"
        ),
        {
          title: res.value,
        }
      );
      resHtml2 && fs.writeFileSync(process.cwd() + "/react.tsx", resHtml2, "utf-8");
  });
